package com.egao.orderB.service.impl;

import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.web.JsonResult;
import com.egao.common.system.entity.User;
import com.egao.orderB.biz.ElectricFenceBiz;
import com.egao.orderB.entity.ElectricFence;
import com.egao.orderB.service.ElectricFenceService;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

//import com.egao.orderB.mapper.ElectricFenceMapper;
//import javax.transaction.Transactional;

/**
 * 电子围栏服务实现类
 * @author : Doman
 * @date : 2020-12-22 15:23:22
 * @version ：1.0
 */
@Service
public class ElectricFenceServiceImpl /*extends ServiceImpl<ElectricFenceMapper, ElectricFence> */implements ElectricFenceService {

	@Autowired
	private ElectricFenceBiz electricFenceBiz;

    /**
    @Override
    public PageResult<ElectricFence> listPage(PageParam<ElectricFence> page) {
        List<ElectricFence> records = baseMapper.listPage(page);
        return new PageResult<>(records, page.getTotal());
    }

    @Override
    public List<ElectricFence> listAll(Map<String, Object> page) {
        return baseMapper.listAll(page);
    } */

    @Override
    public JsonResult list(PageResult2<T> page, ElectricFence electricFence, User loginUser)  throws Exception{
        return electricFenceBiz.list(page,electricFence,loginUser);
    }

    @Override
    public JsonResult list(ElectricFence electricFence, User loginUser) {
        return JsonResult.ok().setData(electricFenceBiz.list(electricFence,loginUser));
    }

    @Override
    public JsonResult getById(ElectricFence electricFence) {
        return JsonResult.ok().setData(electricFenceBiz.getById(electricFence));
    }

    @Override
    public JsonResult save(ElectricFence electricFence, User loginUser) {
        electricFence.setId(electricFenceBiz.save(electricFence, loginUser)+"");
        return JsonResult.ok("添加成功").setData(electricFence);
    }

    @Override
    public JsonResult update(ElectricFence electricFence, User loginUser) {
        if (electricFenceBiz.update(electricFence, loginUser)) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }

    @Override
    public JsonResult remove(ElectricFence electricFence, User loginUser) {
        if (electricFenceBiz.remove(electricFence, loginUser)) {
            return JsonResult.ok("删除成功");
        }
        return JsonResult.error("删除失败");
    }

}
